package pkg

import (
	"crypto/md5"
	"encoding/hex"
	"math/rand"
	"strconv"
)

// 密码加密
func Md5String(s string) string {
	h := md5.New()
	h.Write([]byte(s))
	return hex.EncodeToString(h.Sum(nil))
}

// 生成随机盐
func CodeString(n int) string {
	s := "zxcvbnmasdfghjkwertyuio"
	sle := make([]byte, n)
	for i := range n {
		sle[i] = sle[rand.Intn(len(s))]
	}
	return string(sle)
}

// 生成验证码，
func SmsCodeString() string {
	num := rand.Intn(9000) + 1000
	return strconv.Itoa(num)
}
